﻿namespace TheSafety
{
    using Agent;
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Threading;
    using System.Timers;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Markup;

    [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
    public class ProgressWindow : Window, IComponentConnector
    {
        private EventHandler a;
        private EventHandler b;
        private SynchronizationContext c;
        internal TextBlock d;
        private bool e;

        public ProgressWindow(Window A_0)
        {
            base.Owner = A_0;
            this.InitializeComponent();
        }

        public void a()
        {
            <>c__DisplayClass6 class2;
            this.d.Text = "Uninstalling...";
            ProcessStartInfo info = new ProcessStartInfo(string.Format("{0}/driver" + (ConfigManager.p() ? "/x64" : "") + "/tapinstall.exe", ConfigManager.q()), "remove tap0901") {
                WindowStyle = ProcessWindowStyle.Hidden,
                CreateNoWindow = true,
                UseShellExecute = true
            };
            Process process = new Process {
                EnableRaisingEvents = true,
                StartInfo = info
            };
            if (this.a != null)
            {
                this.a(this, new EventArgs());
            }
            process.Start();
            process.WaitForExit();
            this.d.Text = "Complete";
            System.Timers.Timer a = new System.Timers.Timer(1000.0);
            a.Elapsed += new ElapsedEventHandler(class2.c);
            a.Start();
        }

        public void a(EventHandler A_0)
        {
            EventHandler handler2;
            EventHandler a = this.a;
            do
            {
                handler2 = a;
                EventHandler handler3 = (EventHandler) Delegate.Combine(handler2, A_0);
                a = Interlocked.CompareExchange<EventHandler>(ref this.a, handler3, handler2);
            }
            while (a != handler2);
        }

        [EditorBrowsable(EditorBrowsableState.Never), DebuggerNonUserCode]
        private void a(int A_0, object A_1)
        {
            switch (A_0)
            {
                case 1:
                    ((ProgressWindow) A_1).Loaded += new RoutedEventHandler(this.Window_Loaded);
                    return;

                case 2:
                    this.d = (TextBlock) A_1;
                    return;
            }
            this.e = true;
        }

        public void b()
        {
            <>c__DisplayClass2 class2;
            this.d.Text = "Installing...";
            ProcessStartInfo info = new ProcessStartInfo(string.Format("{0}/driver" + (ConfigManager.p() ? "/x64" : "") + "/tapinstall.exe", ConfigManager.q()), string.Format("install \"{0}/driver" + (ConfigManager.p() ? "/x64" : "") + "/OemWin2k.inf\" tap0901", ConfigManager.q())) {
                WindowStyle = ProcessWindowStyle.Hidden,
                CreateNoWindow = true,
                UseShellExecute = true
            };
            Process process = new Process {
                EnableRaisingEvents = true,
                StartInfo = info
            };
            if (this.a != null)
            {
                this.a(this, new EventArgs());
            }
            process.Start();
            process.WaitForExit();
            this.d.Text = "Complete.";
            System.Timers.Timer a = new System.Timers.Timer(1000.0);
            a.Elapsed += new ElapsedEventHandler(class2.c);
            a.Start();
        }

        public void b(EventHandler A_0)
        {
            EventHandler handler2;
            EventHandler a = this.a;
            do
            {
                handler2 = a;
                EventHandler handler3 = (EventHandler) Delegate.Remove(handler2, A_0);
                a = Interlocked.CompareExchange<EventHandler>(ref this.a, handler3, handler2);
            }
            while (a != handler2);
        }

        public void c(EventHandler A_0)
        {
            EventHandler handler2;
            EventHandler b = this.b;
            do
            {
                handler2 = b;
                EventHandler handler3 = (EventHandler) Delegate.Combine(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        public void d(EventHandler A_0)
        {
            EventHandler handler2;
            EventHandler b = this.b;
            do
            {
                handler2 = b;
                EventHandler handler3 = (EventHandler) Delegate.Remove(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        [DebuggerNonUserCode]
        public void InitializeComponent()
        {
            if (!this.e)
            {
                this.e = true;
                Uri resourceLocator = new Uri("/TheSafety;component/progresswindow.xaml", UriKind.Relative);
                Application.LoadComponent(this, resourceLocator);
            }
        }

        private void Window_Loaded(object A_0, RoutedEventArgs A_1)
        {
            this.c = SynchronizationContext.Current;
        }
    }
}

